package com.cbtx.networklib.factory

import android.text.TextUtils

/**
 * author : joker.peng
 * e-mail : joker@fiture.com
 * date   : 2021/6/29 12:44 PM
 * desc   :
 */
object ExceptionFactory {

    fun checkStringIsNotNull(s: String?, tips: String?) {
        if (TextUtils.isEmpty(tips)) {
            return
        } else {
            throwNullPointerException(tips)
        }
    }

    fun checkParameterIsNotNull(parameter: Any?, tips: String?) {
        if (parameter != null) {
            return
        }
        if (TextUtils.isEmpty(tips)) {
            throwNullPointerException(tips)
        }
    }

    @Throws(NullPointerException::class)
    private fun throwNullPointerException(tips: String?) {
        if (TextUtils.isEmpty(tips)) {
            throw NullPointerException()
        } else {
            throw NullPointerException(tips)
        }
    }
}